# coding: utf-8
from app.modules.common.Errors import ServiceError
from app.modules.common.utils import FileUtil, JsonFileUtil, Jinja2Utils
from config import BaseConfig


def recreate(menu_items, workspace='default'):
    menu_path = BaseConfig.WORKSPACES[workspace] + "/src/config/menu.json"

    menu_items = JsonFileUtil.load(menu_items)
    content = Jinja2Utils.render("menu.jinja2", {'items': menu_items})
    # 4. 写入文件
    FileUtil.write(menu_path, content)
